package com.swotxu.config;

import com.swotxu.bean.Person;
import com.swotxu.web.service.MyService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;

@Configuration //定义当前类为配置类
@ComponentScan(value="com.swotxu"
	// 导入指定规则
	,includeFilters = {
			@Filter(type=FilterType.ANNOTATION,value= {Repository.class}),
			@Filter(type=FilterType.ASSIGNABLE_TYPE,value= {MyService.class}),
			@Filter(type=FilterType.CUSTOM,value= {MytypeFilter.class})
	}
	// 排除指定规则
	,excludeFilters = {
		@Filter(type=FilterType.ANNOTATION,value= {Controller.class})
	}
	// 关闭默认规则
	,useDefaultFilters=false
)	// 包扫描
public class MainConfig {

	/**
	 * @Scope : prototype singleton request session
	 */
	@Scope
	@Bean(name="person") // 给容器中注册一个bean。类型为返回值类型，id为方法名
	public Person person01() {
		System.out.println("MainConfig1 - 给容器中注册person");
		return new Person("李四", 20);
	}
}
